<template>
  <div class="login-container">
<!--    <el-form-->
<!--      ref="loginForm"-->
<!--      :model="loginForm"-->
<!--      :rules="loginRules"-->
<!--      class="login-form"-->
<!--      auto-complete="on"-->
<!--      label-position="left"-->
<!--    >-->

      <div class="title-container">
        <h3 class="title">XX系统用户登陆界面</h3>
      </div>
      <div>
        <el-form class="LoginForm" ref="loginForm" :model="loginForm" :rules="loginRules">
          <el-form-item prop="username">
            <el-input
              v-model="loginForm.username"
              type="text"
              auto-complete="off"
              placeholder="账号"
            >
            </el-input>
          </el-form-item>
          <el-form-item prop="password">
            <el-input
              v-model="loginForm.password"
              type="password"
              auto-complete="off"
              placeholder="密码"
              @keyup.enter.native="handleLogin"
            >
            </el-input>
          </el-form-item>
<!--          <FormItem prop="username" style="width: 100%">-->
<!--            <Input v-model="loginForm.username" class="input" type="text" placeholder="用户名" />-->
<!--          </FormItem>-->
<!--          <FormItem prop="password" style="width: 100%">-->
<!--            <Input v-model="loginForm.password" class="input" type="password" placeholder="密码" />-->
<!--          </FormItem>-->
        </el-form>
      </div>
<!--      <el-button-->
<!--        style="width:100%;background: transparent"-->
<!--        @click.native.prevent="handleLogin"-->
<!--      >-->
        <a class="btn" @click="handleLogin">点击跳转通行证登陆</a>
<!--      </el-button>-->
      <!-- <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;"
        @click.native.prevent="handleLogin">Login</el-button> -->
<!--      <a class="btn" @click="handleSubmit('LoginForm')">点击跳转通行证登陆</a>-->
      <div class="tips">
        <span style="margin-right:20px;">* 通行证的用户名(手机号)必须和user表中授权的手机号保持一致。</span>
      </div>

<!--    </el-form>-->
  </div>
</template>

<script>

import * as Http from 'http'
import Cookies from 'js-cookie'
import store from '@/store'
import router from '@/router'

export default {
  name: 'Login',
  data() {
    return {
      href: process.env.VUE_APP_BASE_API + '/oauth2/authorization/passport',
      loginForm: {
        username: '',
        password: ''
      },
      loginRules: {
        username: [
          { required: true, trigger: 'blur', message: '请输入您的账号' }
        ],
        password: [
          { required: true, trigger: 'blur', message: '请输入您的密码' }
        ]
      },

    }
  },
  methods: {
    // http://127.0.0.1:8080/login/login?username:xxx&password:xxxx
    handleLogin() {
      this.$refs.loginForm.validate(valid => {
        if (valid) {
          this.loading = true
          console.log("===========",this.loginForm)
          this.$store.dispatch('user/Login', this.loginForm).then(() => {
            this.$router.push({ path: this.redirect || '/' }).catch(() => {
            })
          }).catch(() => {
            this.loading = false
          })
        }
      })
    }
  }
}
</script>

<style lang="scss">
/* 修复input 背景不协调 和光标变色 */
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
.btn {
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: #fff;
  border: 1px solid #dcdfe6;
  -webkit-appearance: none;
  text-align: center;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  outline: 0;
  margin: 0;
  -webkit-transition: 0.1s;
  transition: 0.1s;
  font-weight: 500;
  padding: 12px 20px;
  font-size: 14px;
  border-radius: 4px;
  width: 100%;
  margin-top: 60px;
  margin-bottom: 30px;
  color: #fff;
  background-color: #409eff;
  border-color: #409eff;
}
$bg: #283443;
$light_gray: #fff;
$cursor: #fff;

/* reset element-ui css */
.login-container {
  .el-form-item {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    color: #454545;
  }
}
</style>

<style lang="scss" scoped>
$bg: #2d3a4b;
$dark_gray: #889aa4;
$light_gray: #eee;

.login-container {
  min-height: 100%;
  width: 100%;
  background-color: $bg;
  overflow: hidden;

  .login-form {
    position: relative;
    width: 520px;
    max-width: 100%;
    padding: 160px 35px 0;
    margin: 0 auto;
    overflow: hidden;
  }

  .tips {
    font-size: 14px;
    color: #fff;
    margin-bottom: 10px;

    span {
      &:first-of-type {
        margin-right: 16px;
      }
    }
  }

  .title-container {
    position: relative;

    .title {
      font-size: 26px;
      color: $light_gray;
      margin: 0px auto 40px auto;
      text-align: center;
      font-weight: bold;
    }
  }
  .ivu-input::-ms-input-placeholder{  /* Internet Explorer 10-11 */
    color:#999;
  }
  .LoginForm{
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  FormItem{
    margin-top: 12px;
    text-align: center;
  }
  input{
    height: 50px;
    line-height: 50px;
    width: 100%;
    /* 重置内边距和外边距 */
    margin: 0;
    padding: 0;
  }

}
</style>
